//
// C++ Interface: widget
//
// Description: 
//
//
// Author: Os3 s.r.l. <xgui@os3.it>, (C) 2005
//
// Copyright: See COPYING file that comes with this distribution
//
//

#ifdef SWIGPYTHON
	%typemap(out) xgui::Window * { $result = XGUIPyObjectCreate($1, false); }
	%typemap(out) xgui::Container * { $result = XGUIPyObjectCreate($1, false); }
#endif

namespace xgui
{
    %feature("docstring","derives from :class:`xgui.ObjectClass` ") WidgetClass;
	struct WidgetClass : public xgui::ObjectClass
	{
		  WidgetClass();
		  bool isWidget();
		  std::string const &className();

		  virtual bool canContain(xgui::ClassInfo * c);
		  virtual bool canBeContainedIn(xgui::ClassInfo * c);
	};

    %feature("docstring","**DESCRIPTION**\n\nderives from :class:`xgui.Object`\n\n**PROPERTIES**\n\n* **enabled** *(RW):* enables or disables mouse and keyboard input to the widget; set the property value to \"1\" to enable, \"0\" to disable;default: \"1\"\n\n* **tooltip-text** *(RW):* sets or retrieves the text of the widget tooltip; if set to empty string no tooltip will be shown;default: ""\n\n* **visible** *(RW):* if set to \"1\" the widget is visible, if set to \"0\" the widget is hidden;default: \"1\"\n\n* **focused** *(RW):* sets or removes the keyboard focus to the widget; if set to \"1\" the widget has focus, \"0\" otherwise\n\n* **width** *(RO):* gets the widget width in pixels\n\n* **height** *(RO):* gets the widget height in pixels\n\n* **path** *(RO):* retrieves the path of the widget (the same returned by the method :meth:`xgui.Widget.getPath()`)\n\n**EVENTS**\n\n* **ondestroy** *(linked to* :class:`xgui.Callback` *):* fired when the widget is destroyed\n\n* **onfocus** *(linked to* :class:`xgui.Callback` *):* fired when the widget gets keyboard focus\n\n* **onblur**  *(linked to* :class:`xgui.Callback` *):* fired when the widget looses keyboard focus\n\n* **onmousedown** *(linked to* :class:`xgui.TextStatusCallback` *):* fired when the user presses a mouse button while the cursor is in the client area of the widget; the string parameter specifies which button was clicked:it can be \"left\" for left-button, \"right\" for right-button or \"middle\" for middle-button; the status parameter can be one or more of the following values:\n\n * *xgui.mouseLeftMask*-> the left mouse button is pressed\n\n * *xgui.mouseMiddleMask* -> the middle mouse button is pressed\n\n * *xgui.mouseRightMask* -> the right mouse button is pressed\n\n * *xgui.keyControlMask* -> the control key is pressed\n\n * *xgui.keyShiftMask* -> the shift key is pressed\n\n * *xgui.keyAltMask* -> the alt key is pressed\n\n* **onmouseup** *(linked to* :class:`xgui.TextStatusCallback` *):* fired when the user releases a mouse button while the cursor is in the client area of the widget; the string parameter specifies which button was clicked: it can be \"left\" for left-button, \"right\" for right-button or \"middle\" for middle-button; the status parameter can be one or more of the following values:\n\n * *xgui.mouseLeftMask*-> the left mouse button is pressed\n\n * *xgui.mouseMiddleMask* -> the middle mouse button is pressed\n\n * *xgui.mouseRightMask* -> the right mouse button is pressed\n\n * *xgui.keyControlMask* -> the control key is pressed\n\n * *xgui.keyShiftMask* -> the shift key is pressed\n\n * *xgui.keyAltMask* -> the alt key is pressed\n\n* **onmouseclick** *(linked to* :class:`xgui.TextStatusCallback` *):* fired when the user clicks (i.e.: presses and releases) a mouse button while the cursor is in the client area of the widget;the string parameter specifies which button was clicked: it can be \"left\" for left-button, \"right\" for right-button or \"middle\" for middle-button; the status parameter can be one or more of the following values:\n\n * *xgui.mouseLeftMask*-> the left mouse button is pressed\n\n * *xgui.mouseMiddleMask* -> the middle mouse button is pressed\n\n * *xgui.mouseRightMask* -> the right mouse button is pressed\n\n * *xgui.keyControlMask* -> the control key is pressed\n\n * *xgui.keyShiftMask* -> the shift key is pressed\n\n * *xgui.keyAltMask* -> the alt key is pressed\n\n* **onmousedblclick** *(linked to* :class:`xgui.TextStatusCallback` *):* fired when the user double-clicks a mouse button while the cursor is in the client area of the widget;the string parameter specifies which button was clicked: it can be \"left\" for left-button, \"right\" for right-button or \"middle\" for middle-button; the status parameter can be one or more of the following values:\n\n * *xgui.mouseLeftMask*-> the left mouse button is pressed\n\n * *xgui.mouseMiddleMask* -> the middle mouse button is pressed\n\n * *xgui.mouseRightMask* -> the right mouse button is pressed\n\n * *xgui.keyControlMask* -> the control key is pressed\n\n * *xgui.keyShiftMask* -> the shift key is pressed\n\n * *xgui.keyAltMask* -> the alt key is pressed\n\n* **onmousemove** *(linked to* :class:`xgui.TextCallback` *):* fired when the user moves the cursor over the client area of the widget; the string parameter specifies the cursor position relative to the widget upper left corner in the format \"x y\"\n\n* **onmouseout** *(linked to* :class:`xgui.Callback` *):* fired when the cursor leaves the client area of the widget\n\n* **onmouseover** *(linked to* :class:`xgui.Callback` *):* fired when the cursor enters the client area of the widget\n\n* **onhide** *(linked to* :class:`xgui.Callback` *):* fired when the widget becomes hidden\n\n* **onshow** *(linked to* :class:`xgui.Callback` *):* fired when the widget becomes visible\n\n* **onenable** *(linked to* :class:`xgui.Callback` *):* fired when the widget becomes enabled (i.e: it accepts mouse and keyboard input)\n\n* **ondisable** *(linked to* :class:`xgui.Callback` *):* fired when the widget becomes disabled (i.e: it ignores mouse and keyboard input)\n\n* **onresize** *(linked to* :class:`xgui.Callback` *):* fired when the widget size has changed; the string parameter specifies the new size of the widget in the format \"width height\"\n\n* **onmove** *(linked to* :class:`xgui.TextCallback` *):* fired when the widget position has changed;the string parameter specifies the new position of the upper-left corner of the widget in the format \"x y\"; the position is relative to the widget parent\n\n* **onkeydown** *(linked to* :class:`xgui.TextCallback` *):* fired when the user presses a key while the widget has keyboard focus the string parameter specifies the pressed key\n\n* **onkeyup** *(linked to* :class:`xgui.TextCallback` *):* fired when the user releases a key while the widget has keyboard focus; the string parameter specifies the released key\n\n* **onkeypress** *(linked to* :class:`xgui.TextCallback` *):* fired when the user presses and releases a key while the widget has keyboard focus; the string parameter specifies the released key \n\n**METHODS**\n\n") Widget;
	class Widget : public xgui::Object
	{
		private:
			Widget(xgui::Container * parent, xgui::ClassInfo * cinfo = 0, xguimpl::Widget * i = 0);
			virtual ~Widget();

		public:
		    %feature("docstring","returns a pointer to the widget implementation class\n\n*C++*::\n\n xguimpl::Widget * getImpl()\n\n") getImpl;
			xguimpl::Widget * getImpl() { return impl_; }
            %feature("docstring","unlink the widget from its parent\n\n*C++*::\n\n void setAsFloating();\n\n") setAsFloating;
			void setAsFloating();
			%feature("docstring","returns the widget parent container\n\n*C++*::\n\n xgui::Container * getParent();\n\n") getParent;
			xgui::Container * getParent();
			%feature("returns the widget context (i.e.: the top-level window that contains it)\n\n*C++*::\n\n xgui::Window * getContext();\n\n") getContext;
			xgui::Window * getContext();
			%feature("docstring","returns a string representing the widget and all its parents up to the containing top-level window;the returned string has the following format:<top_level_window_id>/<parent_id>[/<parent_id> ...]/<widget_id>\n\n*C++*::\n\n std::string getPath();\n\n") getPath;
			std::string getPath();

            %feature("docstring","links a callback method to the specified event <name>; this method returns false if the event could not be found\n\n*C++*::\n\n bool linkEvent( std::string const &name, xgui::Callback * cb );\n\n") linkEvent;
			bool linkEvent( std::string const &name, xgui::Callback * cb );
			%feature("docstring","returns a callback linked to the specified event <name>\n\n*C++*::\n\n xgui::Callback * getEvent( std::string const &name );\n\n") getEvent;
			xgui::Callback * getEvent( std::string const &name );
			%feature("docstring","returns true if the specified event <name> is linked\n\n*C++*::\n\n bool hasEvent ( std::string const &name );\n\n") hasEvent;
			bool hasEvent ( std::string const &name );

            %feature("docstring","recalculates the dimensions and positions of the widget and all its children\n\n*C++*::\n\n void recalcLayout();\n\n") recalcLayout;
			void recalcLayout();

            %feature("docstring","returns a <x, y> pair that specifies the mouse position relative to the widget upper left corner\n\n*C++*::\n\n std::pair<int, int> getMousePos();\n\n") getMousePos;
			std::pair<int, int> getMousePos();
			%feature("docstring","forces a redraw of the widget\n\n*C++*::\n\n void redraw();\n\n") redraw;
			void redraw();
	};
}

%extend xgui::Widget {
	void delPyOwner(PyObject * pyobj) {
		self->delOwner(pyobj);
	}

	%pythoncode {
		def __del__(self):
			if self.valid: self.delPyOwner(self)
	}
}

%clear xgui::Container *;
%clear xgui::Window *;
